package com.example.boot1.controller;


import com.example.boot1.readyaml.Enterprise;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BootTestController {

    //第一种读取配置文件的方式
    @Value("${server.port}")
    private String prot;



    //第二种读取配置文件的方式
    @Autowired
    private Environment environment;

    //第三种方式
    @Autowired
    private Enterprise enterprise;

    @GetMapping("get")
    public String test(){
        System.out.println(prot);
        System.out.println(environment.getProperty("server.port"));
        System.out.println(enterprise.getName());
        return "hello";
    }
}
